package com.yhgm.utils;

import com.yhgm.constant.Constant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @author xinmiao
 * @description
 * @date 2023/3/11 10:26
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private Integer code;
    private Map<String, Object> data;
    private String msg;

    public static R ok(Map<String, Object> data, String msg) {
        R r = new R();
        r.setCode(Constant.OK_CODE);
        r.setData(data);
        r.setMsg(msg);
        return r;
    }
    public static R ok(String msg) {
        R r = new R();
        r.setCode(Constant.OK_CODE);
        r.setMsg(msg);
        return r;
    }
    public static R error(String msg) {
        R r = new R();
        r.setCode(Constant.ERROR_CODE);
        r.setMsg(msg);
        return r;
    }
}
